# coding:utf-8
from rest_framework import mixins, viewsets

from MSB_ERP.utils.base_views import MultipleDestroyMixin
from goods_info.models import GoodsModel
from production_info.models import BomMaterialModel, BomProcessModel


# from production_info.serializer.bom_serializer import MaterialSerializer, ProcessSerializer, GoodsBomSerializer
from production_info.serializer.bom_serializer import MaterialSerializer, ProcessSerializer, GoodsBomSerializer


class MaterialViewSets(mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin,
                       mixins.RetrieveModelMixin, viewsets.GenericViewSet, MultipleDestroyMixin):
    """
    create:
    生产物料--新增,

    生产物料新增, status: 201(成功), return: 新增生产物料信息

    destroy:
    生产物料--删除

    生产物料删除, status: 204(成功), return: None

    multiple_delete:
    生产物料--批量删除,必传参数：ids=[1,2,3,4...]

    生产物料批量删除, status: 204(成功), return: None

    update:
    生产物料--修改,

    生产物料修改, status: 200(成功), return: 修改后的生产物料信息

    retrieve:
    查询某一个生产物料

    查询指定ID的生产物料, status: 200(成功), return: 生产物料
    """

    queryset = BomMaterialModel.objects.all()
    serializer_class = MaterialSerializer



class ProcessViewSets(mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin,
                      mixins.DestroyModelMixin, viewsets.GenericViewSet, MultipleDestroyMixin):
    """
    create:
    生产工序--新增,

    生产工序新增, status: 201(成功), return: 新增生产工序信息

    destroy:
    生产工序--删除

    生产工序删除, status: 204(成功), return: None

    multiple_delete:
    生产工序--批量删除,必传参数：ids=[1,2,3,4...]

    生产工序批量删除, status: 204(成功), return: None

    update:
    生产工序--修改,

    生产工序修改, status: 200(成功), return: 修改后的生产物料信息

    retrieve:
    查询某一个生产工序

    查询指定ID的生产工序, status: 200(成功), return: 生产工序
    """

    queryset = BomProcessModel.objects.all()
    serializer_class = ProcessSerializer


class GoodsBomViewSet(mixins.RetrieveModelMixin,viewsets.GenericViewSet):
    """
    retrieve:
    查询某一个货品的Bom表数据(包括：BOM表中物料清单和工序清单)


    """
    queryset = GoodsModel.objects.all()
    serializer_class = GoodsBomSerializer
